package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 输血史表
 * @author jing
 *
 */
@JsonApiResource(type = "bloodhistory")
@Table(name = "tnb_blood_history")
@Entity
public class BloodHistory extends BaseEntity {

	private String causes;  //输血的原因
	
	private Integer bloodTime;  //输血的时间
	
	private HealthRecord healthrecord; //对应的健康档案表
	
	private Dicttype bloodReasonType ; //输血原因类型

	@Column(name = "causes")
	public String getCauses() {
		return causes;
	}   

	public void setCauses(String causes) {
		this.causes = causes;
	} 

	@Column(name = "tra_blood_time")
	public Integer getBloodTime() {
		return bloodTime;
	}

	public void setBloodTime(Integer bloodTime) {
		this.bloodTime = bloodTime;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "health_record_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public HealthRecord getHealthrecord() {
		return healthrecord;
	}

	public void setHealthrecord(HealthRecord healthrecord) {
		this.healthrecord = healthrecord;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "bloodreasontype_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBloodReasonType() {
		return bloodReasonType;
	}

	public void setBloodReasonType(Dicttype bloodReasonType) {
		this.bloodReasonType = bloodReasonType;
	}
	

}


































